package com.dkh.recommend.controller;


import com.dkh.recommend.dto.MusicUploadDTO;
import com.dkh.recommend.dto.MusicUploadDTO2;
import com.dkh.recommend.dto.Result;
import com.dkh.recommend.service.ITbMusicService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dkh
 * @since 2022-12-14
 */
@Slf4j
@RestController
@Api(value = "音乐", tags = "音乐-相关", description="音乐-相关")
@RequestMapping("/music")
public class TbMusicController {

    @Autowired
    private ITbMusicService musicService;

//    上传音乐
    @PostMapping("/uploadmusic")
    public Result uploadmusic(@RequestBody MusicUploadDTO musicUploadDTO){
    return musicService.uploadmusic(musicUploadDTO);
    }
    //    上传音乐 （单个标签）
    @PostMapping("/uploadmusic2")
    public Result uploadmusic2(@RequestBody MusicUploadDTO2 musicUploadDTO2 ){
        return musicService.uploadmusic2(musicUploadDTO2);
    }

    @GetMapping("/getallinfo")
    public Result getAllInfo(@RequestParam String musicId){
        return musicService.getAllInfo(musicId);
    }

//     todo 查找音乐
    @GetMapping("/selectmusic")
    public Result selectmusic(@RequestParam String condition ){

        return musicService.selectmusic(condition);
    }

//    分页返回音乐列表：
    @GetMapping("/allmusic/{pageNumber}/{pageSize}")
    public Result allmusic(@PathVariable int pageNumber,@PathVariable int pageSize){
        return musicService.musiclist(pageNumber,pageSize);
//        return null;
    }



//   根据 标签查找音乐列表
    @GetMapping("/getmusicbylabel/{labelId}")
    public Result getmusicbylabel(@PathVariable Long labelId){
    //        return musicService.musiclist();
        return musicService.getmusicbylabel(labelId);
    }

//    查找用户自己上传的音乐
    @GetMapping("/getmymusic")
    public Result getmymusic(){
        return musicService.getmymusic();
    }

//    将音乐放入收藏夹
    @PostMapping("/put2collect/{musicId}/{collectId}")
    public Result put2Collect(@PathVariable String musicId,@PathVariable String  collectId){
        return musicService.put2Collect(musicId,collectId);
    }

//    热门音乐
    @GetMapping("/hotmusic")
    public Result GetHotMusic(){
        return musicService.GetHotMusic();
    }

//    根据音乐Id删除我上传的音乐
        @DeleteMapping("/deletemymusic/{musicId}")
    public Result deleteMyMusic(@PathVariable String musicId){
        return musicService.deleteMyMusic(musicId);
        }

        @GetMapping("/selectbylabelid/{labelId}")
    public Result selectMusicByLabelId(@PathVariable String labelId){
        return musicService.selectMusicByLabelId(labelId);
        }


//        点赞音乐
    @PostMapping("/like/{musicId}")
    public Result likeMusic(@PathVariable String musicId){
        return musicService.likeMusic(musicId);
    }

//    是否已经对音乐点赞
    @GetMapping("/or/not/like/{musicId}")
    public Result islikeMusic(@PathVariable String musicId){
        return musicService.orNotLikeMusic(musicId);
    }






}
